<template>
  <div>
    <el-form ref="form" :rules="rules" :model="form" label-width="300px">
      <el-form-item
        label="运费满减所需最低消费"
        prop="litemall_express_freight_min"
      >
        <el-input
          v-model="form.litemall_express_freight_min"
          size="mini"
        ></el-input>
      </el-form-item>
      <el-form-item
        label="运费满减不足所需运费"
        prop="litemall_express_freight_value"
      >
        <el-input
          v-model="form.litemall_express_freight_value"
          size="mini"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="nono('form')" size="mini">取消</el-button>
        <el-button type="primary" @click="updates('form')" size="mini"
          >确定</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { getList, update } from "@/api/configuration/freight";
export default {
  data() {
    return {
      form: {},
      rules: {
        litemall_express_freight_min: [
          { required: true, message: "不能为空", trigger: "blur" },
        ],
        litemall_express_freight_value: [
          { required: true, message: "不能为空", trigger: "blur" },
        ],
      },
    };
  },
  created() {
    this.getdata();
  },
  methods: {
    getdata() {
      getList().then((res) => {
        console.log(res);
        this.form = res.data;
      });
    },
    updates(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          update(this.form).then((res) => {
            console.log(res);
            if (res.errmsg == "成功") {
              this.$notify({
                title: "成功",
                message: "运费配置修改成功",
                type: "success",
              });
              this.getdata();
            }
          });
        }
      });
    },
    //取消
    nono(formName) {
      this.$refs[formName].resetFields();
      this.getdata();
    },
  },
};
</script>

<style lang="scss" scoped>
</style>